<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
/**
 * @author chaituan@126.com
 */
use EasyWeChat\Foundation\Application;
use EasyWeChat\Payment\Order;
class Test extends CI_Controller {
	
	function imgs(){
		$aa = array('ss'=>1);
		$aa['cc'] = 2;
		var_dump(HTTP_HOST);
		exit("ok");
	}
	
	function hx(){
			$oid = 'H424317329351456';
			$this->load->model(array('admin/Order_model'=>'order','admin/User_model'=>'user'));
			$order = $this->order->getItem(array('oid'=>$oid),'uid,gid');
			$this->user->fx_fl($order);
			AjaxResult_ok("核销成功");
	}
	
	function img() {
		$img = "/res/upload/qrcode/33.jpg";
		$item['qrcode'] = base_url($this->downImage($img, 1));
		exit;
	}
	
	private function downImage($img,$scene){
		if(!is_file(substr($img,1))){
			$app = new Application(array('mini_program'=>array('app_id'=>WX_APPID,'secret'=> WX_APPSecret)));
			// 			$result = $app->mini_program->qrcode->getAppCodeUnlimit($scene,"pages/shop/index");
			$result = $app->mini_program->qrcode->getAppCode("pages/goods/detail?id=1");
			$filename = FCPATH.$img;
			file_put_contents($filename, $result);
		}
		return $img;
	}
	
}
